package com.xintonghua.bussiness.adapter;

import android.app.Activity;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xintonghua.base.adapter.BaseAdapter;
import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.bean.RewardBean;
import com.xintonghua.bussiness.util.MyUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/1/11.
 * 包名：com.xintonghua.bussiness.adapter
 */

public class RewardAdapter extends BaseAdapter<RewardBean, RewardAdapter.RewardViewHolder> {


    public RewardAdapter(Activity mActivity, List<RewardBean> list) {
        super(mActivity, list);
    }

    @Override
    public RewardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.adapter_reward, parent, false);
        return new RewardViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RewardViewHolder holder, int position) {
        RewardBean bean = list.get(position);
        holder.tvRewardName.setText(bean.getNickname());
        holder.tvRewardTime.setText(bean.getCreate_time());
        holder.tvRewardMoney.setText(MyUtils.getMoneys(mActivity, bean.getMoney()));
        holder.tvRewardMoney.setTextColor(ContextCompat.getColor(mActivity, bean.getMoney() >= 0 ? R.color.red : R.color.black));
    }

    class RewardViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_reward_name)
        TextView tvRewardName;
        @BindView(R.id.tv_reward_time)
        TextView tvRewardTime;
        @BindView(R.id.tv_reward_money)
        TextView tvRewardMoney;

        public RewardViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
